/**
 * React Router Configuration
 *
 * 应用路由配置
 * 包含所有页面路由定义
 */

import { createBrowserRouter, Navigate } from 'react-router-dom'
import MainLayout from '@/components/layout/MainLayout'

// 页面组件导入
import DataSourceListPage from '@/pages/datasource/ListPage'
import CollectionTaskListPage from '@/pages/collection/ListPage'
import CollectionTaskDetailPage from '@/pages/collection/DetailPage'
import MetadataSearchPage from '@/pages/metadata/SearchPage'
import TableDetailPage from '@/pages/metadata/DetailPage'
import ExportTaskListPage from '@/pages/export/ListPage'
import RelationshipGraphPage from '@/pages/relationship/GraphPage'

// 临时占位组件
const PlaceholderPage = ({ title }: { title: string }) => (
  <div style={{ padding: '24px' }}>
    <h2>{title}</h2>
    <p>此页面正在开发中...</p>
  </div>
)

export const router = createBrowserRouter([
  {
    path: '/',
    element: <MainLayout />,
    children: [
      {
        index: true,
        element: <Navigate to="/datasources" replace />,
      },
      {
        path: 'datasources',
        element: <DataSourceListPage />,
      },
      {
        path: 'collections',
        element: <CollectionTaskListPage />,
      },
      {
        path: 'collections/:id',
        element: <CollectionTaskDetailPage />,
      },
      {
        path: 'metadata',
        element: <MetadataSearchPage />,
      },
      {
        path: 'metadata/:id',
        element: <TableDetailPage />,
      },
      {
        path: 'exports',
        element: <ExportTaskListPage />,
      },
      {
        path: 'relationships',
        element: <RelationshipGraphPage />,
      },
      {
        path: '*',
        element: <PlaceholderPage title="404 - 页面不存在" />,
      },
    ],
  },
])
